#include<learning.h>


typedef struct stu{
	int num;
	char name[20];
	int scor;
}stu_t;

int main(int argc,char **argv){
	ARGS_CHECK(argc,2);
	stu_t st[3];
	memset(st,0,sizeof(st));
	st[0].num = 1001;
	st[1].num = 1002;
	st[2].num = 1003;
	strcpy(st[0].name , "xiaoming");
	strcpy(st[1].name , "honghong");
	strcpy(st[2].name ,"laozhang");
	st[0].scor = 99;
	st[1].scor = 98;
	st[2].scor = 97;
	int fd = open(argv[1],O_RDWR|O_CREAT,0666);
	RET_CHECK(fd,-1,"open");
	int ret = write(fd,st,sizeof(st));


	RET_CHECK(ret,-1,"write");
	memset(st,0,sizeof(st));
	lseek(fd,0,SEEK_SET);
	ret = read(fd,st,sizeof(st));
	RET_CHECK(ret,-1,"read");
	for(int i = 0;i<3;++i)
	{
		printf("%d %s %d\n",st[i].num,st[i].name,st[i].scor);

	}

	close(fd);
	return 0;

}
